<%-- 
    Document   : detalleDocente
    Created on : 03-22-2010, 10:16:56 PM
    Author     : Eduardo Cerritos
--%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<link href="../css/estilos.css" rel="stylesheet" type="text/css" />
<%@ page import="java.util.*" %>
<%@ page import="beans.*" %>
<%@page import="com.sun.org.apache.xerces.internal.impl.dv.util.Base64" %>
<jsp:useBean id="Materias" scope="request" class="databeans.MateriaDataBean" />
<jsp:useBean id="Docentes" scope="request" class="databeans.DocenteDataBean" />
<%
    String codigo = request.getParameter("codigo");
    DocenteBean docente = Docentes.getDocente(codigo);
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>EME:Detalle Docente</title>
        <script language="javascript" type="text/javascript" src="../js/utilidades.js"></script>
    </head>

    <body >
        <sec:authorize ifAnyGranted="ROLE_SYSTEM, ROLE_DOCENTE">

        <table  border="0" width="100%">
            <thead>
                <tr>
                    <th>
                      <h1><img src="../images/EME2.png" width="175px"></h1>
                    </th>

                     <sec:authorize ifNotGranted="ROLE_DOCENTE">
                     <th>
                         <h1><img src="../images/headers/verDocente.png" alt="ver docente" ></h1>
                    </th>
                    </sec:authorize>
                    <sec:authorize ifAllGranted="ROLE_DOCENTE">
                        <th>
                            <h1><img src="../images/headers/verPerfil2.png.png" alt="ver perfil"></h1>
                        </th>
                    </sec:authorize>

                </tr>
            </thead>
            <tbody>

                <tr>
                    <td width="200px" valign="top">
                         <div>
                            <jsp:include page="menu.jsp"/>
                        </div>
                    </td>
                    <td><center>


                               <center>
                                   <h3>Datos Generales</h3>
                                   <form action="../editDocente" method="post" name="form1" onsubmit="return validaForm(this)">
                                       <table class="tabla2" border="0" style="margin: 0 auto; text-align: left;">
                                    <tbody>
                                       <tr>
                                           <td>
                                               Codigo:
                                           </td>
                                            <td>
                                                <input name="docente"
                                                       size="10"
                                                       maxlength="7"
                                                       value="<%= docente.getCodigo() %>"
                                                       disabled>
                                                <input type="hidden" name="codigo" value="<%= docente.getCodigo()%>" />
                                           </td>
                                       </tr>
                                       <tr>
                                           <td>
                                               Nombres:
                                           </td>
                                           <td>
                                               <input name="nombre"
                                                      size="35"
                                                      maxlength="30"
                                                      value="<%= docente.getNombre() %>">
                                           </td>
                                       </tr>
                                        <tr>
                                           <td>
                                               Apellidos:
                                           </td>
                                           <td>
                                               <input name="apellido"
                                                      size="35"
                                                      maxlength="30"
                                                      value="<%= docente.getApellido() %>">
                                           </td>
                                       </tr>
                                       <tr>
                                           <td>
                                               e-Mail:
                                           </td>
                                           <td>
                                              <input id="email"
                                                     name="email"
                                                     size="50"
                                                     maxlength="50"
                                                     value="<%= docente.getEmail() %>" onchange="validarEmail(this)">
                                           </td>
                                       </tr>
                                       <sec:authorize ifAllGranted="ROLE_DOCENTE">
                                        <tr>
                                           <td>
                                               Tel&eacute;fono celular:
                                           </td>
                                           <td>
                                              <input name="telefono"
                                                     size="10"
                                                     maxlength="8"
                                                     value="<%= new String(Base64.decode(docente.getTelefono())) %>"
                                                     onchange="validarCel(this)">
                                           </td>
                                       </tr>
                                       </sec:authorize>
                                       <tr>
                                           <td colspan="2"><button type="submit">Guardar cambios</button> </td>
                                       </tr>
                                   </tbody>
                               </table>
                                   </form>

                                   <h3>Materias</h3>
                               <table class="tabla1">
                                       <thead>
                                           <tr>
                                               <th width="150px">CodMateria</th>
                                               <th>Nombre de Materia</th>
                                           </tr>
                                       </thead>
                                       <tbody>

                                    <%
                                    List listaMat = Materias.getListaMateriasByDocente(codigo);
                                    Iterator it = listaMat.iterator();
                                    int i=0;
                                    while (it.hasNext()){
                                        MateriaBean materia = (MateriaBean)it.next();

                                    %>
                                    <tr>
                                    <td><%= materia.getCodMateria()%></td>
                                    <td><%= materia.getNomMateria()%></td>
                                    <sec:authorize ifAllGranted="ROLE_SYSTEM">
                                    <td><a href="../EliminarMateriaDocente?codmateria=<%= materia.getCodMateria()%>&codigo=<%=docente.getCodigo()%>">Quitar Materia</a></td>
                                    </sec:authorize>
                                    </tr>
                                    <%
                                    }
                                    %>
                                    </tbody>
                               </table>
                                    <sec:authorize ifAllGranted="ROLE_SYSTEM">
                                    <hr width="70%">
                                    <form name="form2"
                                        ACTION="../AgregarMateriaDocente"
                                        METHOD="POST">
                                        <input type="hidden" name="codigo" value="<%=docente.getCodigo()%>">
                                        <table>
                                            <thead>
                                                <tr>
                                                    <th>
                                                        <h3>Agregar Materia</h3>
                                                    </th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <tr>
                                                    <td>
                                                        <%
                                                        List listaMatNuevas = Materias.getListaMateriasDistintasByDocente(codigo);
                                                        Iterator ite = listaMatNuevas.iterator();
                                                        while (ite.hasNext()){
                                                            MateriaBean materia = (MateriaBean)ite.next();

                                                        %>
                                                        <input name="materias" type="checkbox" value="<%= materia.getCodMateria()%>">
                                                            <%= materia.getNomMateria()%>
                                                       <br>
                                                        <%
                                                        }
                                                        %>

                                                   </td>
                                               </tr>
                                               <tr>
                                                   <td align="center">
                                                       <input type="submit" value="Aceptar">
                                                   </td>
                                               </tr>
                                            </tbody>
                                        </table>
                                    </form>
                                </sec:authorize>
                            </center>

                        </center>
                    </td>
                </tr>
            </tbody>
        </table>
        <div align="left">
        <jsp:include page="barrausuario.jsp"/>
        </div>
        </sec:authorize>
    </body>
</html>
